package com.dragon.pear.modules.trade.service.assistants.converters;

import java.sql.Timestamp;
import com.dragon.common.base.utils.ConvertUtil;
import com.dragon.common.base.utils.DbUtil;
import com.dragon.common.spring.annotations.DataConverter;
import com.dragon.common.spring.business.base.BaseConverter;
import com.dragon.utils.TimeUtil;
import com.dragon.pear.modules.trade.domain.entity.TradeGoodsDetailsEntity;
import com.dragon.pear.modules.trade.web.model.params.create.TradeGoodsDetailsCreateParam;
import com.dragon.pear.modules.trade.web.model.params.update.TradeGoodsDetailsUpdateParam;
import com.dragon.pear.modules.trade.web.model.results.TradeGoodsDetailsResult;

/**
 * @author Chris Chan
 * Create on 2025-09-30 22:06
 * Use for: 商品详情 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class TradeGoodsDetailsConverter implements BaseConverter<
        TradeGoodsDetailsEntity,
        TradeGoodsDetailsCreateParam,
        TradeGoodsDetailsUpdateParam,
        TradeGoodsDetailsResult> {
    @Override
    public TradeGoodsDetailsEntity fromParam(TradeGoodsDetailsCreateParam param) {
        TradeGoodsDetailsEntity entity = new TradeGoodsDetailsEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public TradeGoodsDetailsEntity fromUpdateParam(TradeGoodsDetailsUpdateParam param) {
        TradeGoodsDetailsEntity entity = ConvertUtil.convert(param, TradeGoodsDetailsEntity.class);
        return entity;
    }

    @Override
    public TradeGoodsDetailsResult toResult(TradeGoodsDetailsEntity entity) {
        TradeGoodsDetailsResult result = ConvertUtil.convert(entity,TradeGoodsDetailsResult.class);
        return result;
    }
}